<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style> 
      .bg{
          background-color: red;
          width: 200px;
          height: 200px;
      }
     </style>
</head>
<body>
    <div  class="bg" id="bg"> </div>
    
</body>
<script>
    //获取id值是特定值得网页元素再js中的表示方式
    var bg = document.getElementById("bg");
    bg.onclick = function(){
        alert("div被点击了")
    }
    //当鼠标移动到div上时，在控制台打印输出
    //鼠标箭头移上了div
    var bg = document.getElementById("bg");
    bg.onmouseover =function(){
        alert("鼠标箭头移动奥div上")
    }
    </Script>
</html>